<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
  <style>
    html,
    body {
      margin: 0;
      padding: 0;
      background-color: lightpink;
    }

    .one {
      width: 200px;
      height: 100px;
      margin-top: 300px;
      margin-left: 200px;
      background-color: wheat;
    }
  </style>
</head>

<body>
  <div class="one"></div>
  <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>

  <script>


    var Ts;

    TS = {
      window: window,

      ScreenWidth: window.screen.width,//屏幕宽
      ScreenHeight: window.screen.height,//屏幕高

      WindowLeft: window.screenLeft + 8,
      WindowTop: window.screenTop,

      ViewLeft: window.screenLeft + 8,
      ViewTop: window.screenTop + (window.outerHeight - window.innerHeight - 8)

    }

    var showDic = {
      window: '窗口本身对象',
      ScreenWidth: '屏幕宽',
      ScreenHeight: '屏幕高',

      WindowTop: "窗口距顶",
      WindowLeft: "窗口距左",

      ViewTop: "文档距顶",
      ViewLeft: "文档距左",
    }

    for (x in TS) {
      console.log(TS[x], x + ":" + showDic[x]);
    }

    $(function () {

      $(".one").click(function () {
        var dom = this;

        console.log($(dom).offset().top, "==========元素距文档顶==========");

        console.log($(dom).offset().left, "==========元素距文档左==========")


        console.log(TS.ViewTop + $(dom).offset().top, "==========元素相对屏幕顶==========");

        console.log(TS.ViewLeft + $(dom).offset().left, "==========元素相对屏幕左==========")

      });

    })



  </script>
</body>

</html>